import { ItemCategory } from '../shared';

export enum EquipmentSlot {
  Primary = 'primary',
  Secondary = 'secondary',
  Head = 'head',
  Chest = 'chest',
  Hands = 'hands',
  Feet = 'feet',
  Ring1 = 'ring1',
  Ring2 = 'ring2',
  Charm = 'charm',
}

export type InventoryCategory =
  | 'weapon'
  | 'ammo'
  | 'gear'
  | 'attachment'
  | 'ring'
  | 'charm'
  | 'med'
  | 'food'
  | 'tool'
  | 'throwable'
  | 'misc';

export interface ItemBase {
  id: string;
  name: string;
  category: InventoryCategory;
  quantity: number;
  maxStack?: number;
  ammoType?: string;
  uses?: number;
}

export function toSharedCategory(category: InventoryCategory): ItemCategory {
  switch (category) {
    case 'weapon':
      return ItemCategory.Weapon;
    case 'ammo':
      return ItemCategory.Ammo;
    case 'gear':
      return ItemCategory.Equipment;
    case 'attachment':
      return ItemCategory.Attachment;
    case 'ring':
      return ItemCategory.Ring;
    case 'charm':
      return ItemCategory.Charm;
    case 'med':
      return ItemCategory.Medical;
    case 'food':
      return ItemCategory.Food;
    case 'tool':
      return ItemCategory.Tool;
    case 'throwable':
      return ItemCategory.Throwable;
    default:
      return ItemCategory.Misc;
  }
}

// Helper factory: misc.key with uses
export function createKeyItem(id: string, name: string, uses = 1): ItemBase {
  return { id, name, category: 'misc', quantity: 1, uses };
}

export default {
  EquipmentSlot,
  createKeyItem,
};


